// 按需（懒）加载
function loadView(view, folder) {
    if (folder) {
        return () => import(/* webpackChunkName: "view-[request]" */ `@/views/${folder}/${view}.vue`)
    } else {
        return () => import(/* webpackChunkName: "view-[request]" */ `@/views/${view}.vue`)
    }
}



let all = [
	{
	    path: '/train',
	    name: 'Train',
	    component: loadView('Index', 'train'),
	    meta: { title: '培训', icon: 'iconpeixun' },
	    children: [
	        {
	            path: 'trainManager',
	            name: 'TrainManager',
	            component: loadView('TrainManager', 'train'),
	            meta: { fatherName:'Train',title: '培训管理',fatherTitle:'培训',isShow:true},
	        },
			// {
			//     path: 'expertManager',
			//     name: 'ExpertManager',
			//     component: loadView('ExpertManager', 'train'),
			//     meta: { fatherName:'Train',title: '专家管理',fatherTitle:'培训',isShow:true},
			// },
	        {
	            path: 'trainType',
	            name: 'TrainType',
	            component: loadView('TrainType', 'train'),
	            meta: {fatherName:'Train', title: '培训类型' ,fatherTitle:'培训',isShow:true},
	        },
	        {
	            path: 'attendanceManager',
	            name: 'AttendanceManager',
	            component: loadView('AttendanceManager', 'train'),
	            meta: { fatherName:'Train',title: '考勤管理',fatherTitle:'培训',isShow:true},
	        },
			{
			    path: 'createTrain',
			    name: 'CreateTrain',
			    component: loadView('CreateTrain', 'train'),
			    meta: {fatherName:'Train', title: '创建培训' ,fatherTitle:'培训'},
			},
	    ]
	},
	// {
	//     path: '/course',
	//     name: 'Course',
	//     component: loadView('Index', 'course'),
	//     meta: { title: '课程', icon: 'iconkecheng' },
	//     children: [
	//         {
	//             path: 'courseManager',
	//             name: 'CourseManager',
	//             component: loadView('CourseManager', 'course'),
	//             meta: { fatherName:'Course',title: '课程管理',fatherTitle:'课程',isShow:true},
	//         },
	//         {
	//             path: 'courseType',
	//             name: 'CourseType',
	//             component: loadView('CourseType', 'course'),
	//             meta: { fatherName:'Course',title: '课程分类' ,fatherTitle:'课程',isShow:true},
	//         },
	// 		{
	// 		    path: 'taskManager',
	// 		    name: 'TaskManager',
	// 		    component: loadView('TaskManager', 'course'),
	// 		    meta: { fatherName:'Course',title: '作业管理' ,fatherTitle:'课程',isShow:true},
	// 		}
	//     ]
	// },
	// {
	//     path: '/microLecture',
	//     name: 'MicroLecture',
	//     component: loadView('Index', 'micro_lecture'),
	//     meta: { title: '微课管理', icon: 'iconweike' },
	//     children: [
	//         {
	//             path: 'microLectureReview',
	//             name: 'MicroLectureReview',
	//             component: loadView('MicroLectureReview', 'micro_lecture'),
	//             meta: { fatherName:'MicroLecture',title: '微课评审',fatherTitle:'微课管理',isShow:true},
	//         },
	//         {
	//             path: 'opinionManager',
	//             name: 'OpinionManager',
	//             component: loadView('OpinionManager', 'micro_lecture'),
	//             meta: { fatherName:'MicroLecture',title: '意见管理' ,fatherTitle:'微课管理',isShow:true},
	//         },
	// 		{
	// 		    path: 'reviewRules',
	// 		    name: 'ReviewRules',
	// 		    component: loadView('ReviewRules', 'micro_lecture'),
	// 		    meta: { fatherName:'MicroLecture',title: '评审规则' ,fatherTitle:'微课管理',isShow:true},
	// 		}
	//     ]
	// },
	// {
	//     path: '/questionnaire',
	//     name: 'Questionnaire',
	//     component: loadView('Index', 'questionnaire'),
	//     meta: { title: '问卷', icon: 'iconwenjuan' },
	//     children: [
	//         {
	//             path: 'questionnaireManager',
	//             name: 'QuestionnaireManager',
	//             component: loadView('MicroLectureReview', 'questionnaire'),
	//             meta: { fatherName:'Questionnaire',title: '问卷管理',fatherTitle:'问卷',isShow:true},
	//         },
	//         {
	//             path: 'questionnaireType',
	//             name: 'QuestionnaireType',
	//             component: loadView('QuestionnaireType', 'questionnaire'),
	//             meta: { fatherName:'Questionnaire',title: '问卷类型' ,fatherTitle:'问卷',isShow:true},
	//         },
	// 		{
	// 		    path: 'questionnaireTemplate',
	// 		    name: 'QuestionnaireTemplate',
	// 		    component: loadView('QuestionnaireTemplate', 'questionnaire'),
	// 		    meta: { fatherName:'Questionnaire',title: '问卷模板' ,fatherTitle:'问卷',isShow:true},
	// 		}
	//     ]
	// },
	// {
	//     path: '/advice',
	//     name: 'Advice',
	//     component: loadView('Index', 'advice'),
	//     meta: { title: '咨询', icon: 'iconzixun' },
	//     children: [
	//         {
	//             path: 'apptManager',
	//             name: 'ApptManager',
	//             component: loadView('ApptManager', 'advice'),
	//             meta: { fatherName:'Advice',title: '预约管理',fatherTitle:'咨询',isShow:true},
	//         },
	//         {
	//             path: 'timeSlotManager',
	//             name: 'TimeSlotManager',
	//             component: loadView('TimeSlotManager', 'advice'),
	//             meta: { fatherName:'Advice',title: '预约时段管理' ,fatherTitle:'咨询',isShow:true},
	//         }
	//     ]
	// },
	{
	    path: '/news',
	    name: 'News',
	    component: loadView('Index', 'news'),
	    // redirect: '/news/newsList',
	    meta: { title: '新闻管理', icon: 'iconxinwen' },
	    children: [
	        {
	            path: 'newsList',
	            name: 'NewsList',
	            component: loadView('NewsList', 'news'),
	            meta: {fatherName:'News', title: '新闻列表',fatherTitle:'新闻管理',code:"NewsList",isShow:true},
	        },
			{
			    path: 'newsType',
			    name: 'NewsType',
			    component: loadView('NewsType', 'news'),
			    meta: {fatherName:'News', title: '新闻类别',fatherTitle:'新闻类别',isShow:true},
			},
			{
			    path: 'previewNews',
			    name: 'PreviewNews',
			    component: loadView('PreviewNews', 'news'),
			    meta: {fatherName:'News', title: '新闻预览',fatherTitle:'新闻管理',code:"NewsList"},
			},
			{
			    path: 'createNews',
			    name: 'CreateNews',
			    component: loadView('CreateNews', 'news'),
			    meta: {fatherName:'News', title: '发布新闻',fatherTitle:'新闻管理',code:"NewsList"},
			}
	    ]
	},
	// {
	//     path: '/questionBank',
	//     name: 'QuestionBank',
	//     component: loadView('Index', 'questionBank'),
	//     meta: { title: '题库', icon: 'icontiku' },
	//     children: [
	//         {
	//             path: 'taskBank',
	//             name: 'TaskBank',
	//             component: loadView('TaskBank', 'questionBank'),
	//             meta: { fatherName:'QuestionBank',title: '预约管理',fatherTitle:'题库',isShow:true},
	//         },
	//         {
	//             path: 'questionnaireBank',
	//             name: 'QuestionnaireBank',
	//             component: loadView('QuestionnaireBank', 'questionBank'),
	//             meta: { fatherName:'QuestionBank',title: '问卷题库' ,fatherTitle:'题库',isShow:true},
	//         }
	//     ]
	// },
	// {
	//     path: '/certificate',
	//     name: 'Certificate',
	//     component: loadView('Index', 'certificate'),
	//     meta: { title: '证书', icon: 'iconzhengshu' },
	//     children: [
	//         {
	//             path: 'certificateList',
	//             name: 'CertificateList',
	//             component: loadView('CertificateList', 'certificate'),
	//             meta: {fatherName:'Certificate', title: '',fatherTitle:'证书',code:"CertificateList"},
	//         }
	//     ]
	// },
	{
	    path: '/system',
	    name: 'System',
	    component: loadView('Index', 'system'),
	    meta: { title: '系统设置', icon: 'iconshezhi' },
	    children: [
	        {
	            path: 'organizationManager',
	            name: 'OrganizationManager',
	            component: loadView('OrganizationManager', 'system'),
	            meta: { fatherName:'System',title: '组织管理',fatherTitle:'系统设置',isShow:true},
	        },
			{
			    path: 'academyManager',
			    name: 'AcademyManager',
			    component: loadView('AcademyManager', 'system'),
			    meta: {fatherName:'AcademyManager', title: '学院管理' ,fatherTitle:'系统设置',isShow:true},
			},
			{
			    path: 'teacherManager',
			    name: 'TeacherManager',
			    component: loadView('TeacherManager', 'system'),
			    meta: {fatherName:'System', title: '教员管理',fatherTitle:'系统设置',isShow:true},
			},
			{
			    path: 'roleManager',
			    name: 'RoleManager',
			    component: loadView('RoleManager', 'system'),
			    meta: { fatherName:'System',title: '角色管理',fatherTitle:'系统设置',isShow:true},
			},
			{
			    path: 'userManager',
			    name: 'UserManager',
			    component: loadView('UserManager', 'system'),
			    meta: {fatherName:'AcademyManager', title: '用户管理' ,fatherTitle:'系统设置',isShow:true},
			},
			{
			    path: 'systemLog',
			    name: 'SystemLog',
			    component: loadView('SystemLog', 'system'),
			    meta: {fatherName:'System', title: '系统日志',fatherTitle:'系统设置',isShow:true},
			}
	    ]
	}
]

import store from "@/store"
export const setRouter = (to)=>{
	
	// let authList = store.state.user.authorityList;
	// let routers = [];
	// if(authList){
	// 	all.forEach(rt=>{
	// 		for(let i = 0;i<authList.length;i++){
	// 			let el = authList[i];
	// 			if(rt.name == el.compCode){
	// 				if(rt.children && el.subMenus){
	// 					let children = [];
	// 					rt.children.forEach(crt=>{
	// 						let crtCode = crt.name;
	// 						if(crt.meta.code){
	// 							crtCode = crt.meta.code;
	// 						}
	// 						crtCode.split(",");
	// 						for(let j = 0;j < el.subMenus.length ; j++){
	// 							let cel = el.subMenus[j];
	// 							if(crtCode.includes(cel.compCode)){
	// 								children.push(crt);
	// 								break;
	// 							}
	// 						}
	// 					})
	// 					if(children.length > 0){
	// 						rt.redirect = rt.path+"/"+children[0].path;
	// 						if(children[0].meta.query){
	// 							rt.meta.query = children[0].meta.query;
	// 						}
	// 						rt.children = children;
	// 					}
	// 				}
	// 				routers.push(rt);
	// 				break;
	// 			}
	// 		}
	// 	})
	// }
	// console.log(routers)
	
	let routers = all;
	return routers;
	
}